@extends('layouts.admin')
@push('morecss')
    <!-- Bootstrap Treeview -->
    <link rel="stylesheet" type="text/css" href="//cdn.tudouyu.cn/bootstrap-treeview/dist/bootstrap-treeview.min.css"/>
    <!-- jsTree -->
    <link href="//cdn.tudouyu.cn/jstree/dist/themes/default/style.min.css" rel="stylesheet">
@endpush

@push('morescript')
    <!-- Bootstrap Treeview -->
    <script src="//cdn.tudouyu.cn/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
    <!-- jsTree -->
    <script src="//cdn.tudouyu.cn/jstree/dist/jstree.min.js"></script>
    <script type="application/javascript">
        let page_params = {
            @can('admin.sysrole.index')
            url_list: '{{ route('admin.sysrole.index') }}',
            @endcan
            @can('admin.sysrole.create')
            url_add: '{{ route('admin.sysrole.create') }}',
            @endcan
            @can('admin.sysrole.update')
            url_edit: '{{ route('admin.sysrole.update') }}',
            @endcan
            @can('admin.sysrole.saveperm')
            url_perm: '{{ route('admin.sysrole.saveperm') }}',
            @endcan
            @can('admin.sysrole.destroy')
            url_del: '{{ route('admin.sysrole.destroy') }}',
            @endcan
            data_perm : @json($permList),
        };
    </script>
    <!-- require page js -->
    <script src="{{ mix('js/admin/sysrole_index.js') }}"></script>
@endpush
@section('content')
    <!-- 主体内容 -->
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="ibox-content m-b-sm border-bottom">
            <div class="row">
                <div class="col-sm-2">
                    <div class="form-group">
                        <label class="control-label" for="product_name">&nbsp;&nbsp;</label>
                        <div>
                            @can('admin.sysrole.create')
                                <button class="btn btn-primary" type="button" id="btn-add"><i class="fa fa-plus"></i>
                                    添加角色
                                </button>
                            @endcan
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>角色列表</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="treeview" id="tree"></div>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <!-- 节点操作询问层 -->
    <div class="ibox-content" id="box_ask" style="display: none">
        <div class="form-horizontal m-t">
            <div class="form-group" style="text-align: center">
                @can('admin.sysrole.create')
                    <button class="btn btn-success" type="button" id="btn-add-child">
                        <i class="fa fa-plus"></i>
                        添加子角色
                    </button>
                @endcan
                @can('admin.sysrole.update')
                    <button class="btn btn-primary" type="button" id="btn-edit">
                        <i class="fa fa-edit"></i>
                        编辑角色
                    </button>
                @endcan
                @can('admin.sysrole.saveperm')
                    <button class="btn btn-primary" type="button" id="btn-editperm">
                        <i class="fa fa-edit"></i>
                        权限编辑
                    </button>
                @endcan
                @can('admin.sysrole.destroy')
                    <button class="btn btn-danger" type="button" id="btn-del">
                        <i class="fa fa-trash-o"></i>
                        删除角色
                    </button>
                @endcan
            </div>
        </div>
    </div>
    <!-- 节点操作询问层 -->

    <!-- 角色编辑model -->
    <div class="ibox-content" id="box-form" style="display: none">
        <form role="form" id="form" method="post" class="form-horizontal">
            <input type="hidden" name="role_id" id="role_id" value="0">
            <input type="hidden" name="parent_id" id="parent_id" value="0">
            <div class="form-group">
                <label class="col-sm-2 control-label">角色定义名</label>
                <div class="col-sm-10">
                    <input type="text" placeholder="输入角色定义名" class="form-control" name="name" id="name">
                    <span class="help-block m-b-none">英文唯一标识，如：supper-admin</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">角色显示名</label>
                <div class="col-sm-10">
                    <input type="text" placeholder="输入角色显示名" class="form-control" name="display_name" id="display_name">
                    <span class="help-block m-b-none">中文显示名，如：超级管理员</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">描述</label>
                <div class="col-sm-10">
                    <textarea class="form-control" placeholder="输入描述" name="description" id="description"></textarea>
                    <span class="help-block m-b-none">角色说明</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-4">
                    <input type="number" min="1" step="1" name="order_num" id="order_num" value="999" class="form-control">
                    <span class="help-block m-b-none">数字越小越靠前</span>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button class="btn btn-primary" type="button" id="btn-sub">
                        保存
                    </button>
                </div>
            </div>
        </form>
    </div>
    <!-- 权限编辑model -->
    <div class="ibox-content" id="box-form-perm" style="display: none">
        <form id="permform" method="POST" class="form-horizontal">
            <input type="hidden" name="role_id" id="role_id" value="0">
            <div class="form-group">
                <div id="jstree">
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4">
                    <button class="btn btn-primary" type="button" id="btn-subperm">
                        保存
                    </button>
                </div>
            </div>
        </form>
    </div>
@endsection